import time

from selenium import webdriver
# from selenium.webdriver import ActionChains, Keys
from selenium.webdriver.common.by import By



# 账号密码数据
account = '20207598'
password = 'Hxh20011214'

# 数字化实训平台
url_1 = 'http://digit.chuangnengkeji.com/'
# 创能实训
url_2 = 'https://swxykdsx.chuangnengkeji.com/user/node?nodeId=1421338'
# 戴希实训
url_3 = 'https://swxykdsx.daixiwangluo.com/user/node?nodeId=1421359'
# 频蓝实训
url_4 = 'https://swxykdsx.pinlankeji.com/user/node?nodeId=1421383'


def openPage():
    # 打开主页面
    driver.get(url_1)

    # 打开第一个页面
    driver.execute_script("window.open('');")
    driver.switch_to.window(driver.window_handles[1])
    driver.get(url_2)
    input()

    # 打开第二个页面
    driver.execute_script("window.open('');")
    driver.switch_to.window(driver.window_handles[2])
    driver.get(url_3)
    input()

    # 打开第三个页面
    driver.execute_script("window.open('');")
    driver.switch_to.window(driver.window_handles[3])
    driver.get(url_4)
    input()


def input():
    driver.find_element(By.XPATH, '//*[@id="username"]').send_keys(account)
    driver.find_element(By.XPATH, '//*[@id="password"]').send_keys(password)
    driver.find_element(By.XPATH, '//*[@id="remember"]').click()


if __name__ == '__main__':
    # driver = webdriver.Safari()
    driver = webdriver.Edge(r'/Users/caiyoupeng00/Desktop/msedgedriver')
    openPage()
    # time.sleep(100)

    # ActionChains(driver).key_down(Keys.CONTROL).send_keys("t").key_up(Keys.CONTROL).perform()

    # # 获取 Cookies
    # time.sleep(5)
    # driver.find_element(By.XPATH, '//*[@id="loginForm"]/div/div[5]/div/input[2]').click()
    # time.sleep(10)
    # cookie1 = driver.get_cookies()
    # print(cookie1)
